package vip.ifmm.lehouse.api.gateway.controller.user;

import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import vip.ifmm.lehouse.common.dto.ServerResponse;
import vip.ifmm.lehouse.user.service.api.UserRegisterService;

/**
 * 用户注册服务控制器
 *
 * @author Fish
 * <p>Email: fishinlove@163.com</p>
 * <p>created by 2019/06/16 21:55:44</p>
 */
@RestController
@RequestMapping(path = "/user")
public class UserRegisterController {

    @Reference
    private UserRegisterService registerService = null;

    // 用户注册
    @PostMapping(path = "/register")
    public ServerResponse register(String code, String email, String password) {
        return registerService.register(code, email, password);
    }

    // 检查邮箱是否已经被使用
    @GetMapping(path = "/isEmailUsed/{email}")
    public ServerResponse isEmailUsed(@PathVariable("email") String email) {
        return registerService.isEmailUsed(email);
    }

    // 给指定邮箱发送注册验证码
    @PostMapping(path = "/sendRegisterCode/{email}")
    public ServerResponse sendRegisterCode(@PathVariable("email") String email) {
        return registerService.sendRegisterCode(email);
    }
}
